import type {RouteRecordRaw} from "vue-router";
import {constantRoutes} from "@/router";
import {store, userRouterStore} from "@/store";
import router from "@/router";

import MenuAPI, {type RouteVO} from "@/api/system/menu";
import {getUserRouter} from "@/utils/auth";

const modules = import.meta.glob("../../views/**/**.vue");
const Layout = () => import("@/layout/index.vue");
const router = [

    {
        "path": "/analyse",
        "component": "Layout",
        "name": "analyse",
        "meta": {
            "title": "分析室",
            "icon": "cascader",
            "hidden": false,
            "alwaysShow": true,
            "params": null
        },
        "children": [
            {
                "path": "analyseIndex",
                "component": "system/analyse/index",
                "name": "analyseIndex",
                "meta": {
                    "title": "分析单",
                    "icon": "cascader",
                    "hidden": false,
                    "alwaysShow": true,
                    "params": null
                }
            },
            {
                "path": "analyse-details",
                "component": "system/analyse/details",
                "meta": {
                    "title": "分析单详情",
                    "hidden": true
                }
            },
            {
                "path": "analyse-apportion",
                "component": "system/analyse/apportion",
                "meta": {
                    "title": "分析分派",
                    "hidden": true
                }
            },
            {
                "path": "sample",
                "component": "system/sampleAnalyse/index",
                "name": "sample",
                "meta": {
                    "title": "样品分析",
                    "icon": "cascader",
                    "hidden": false,
                    "alwaysShow": true,
                    "params": null
                }
            },
            {
                "path": "sample-analysis",
                "component": "system/sampleAnalyse/analysis",
                "name": 'sample-analysis',
                "meta": {
                    "title": "样品分析",
                    "hidden": true
                }
            },
            {
                "path": "sample-taskReceiving",
                "component": "system/sampleAnalyse/taskReceiving",
                "name": 'sample-taskReceiving',
                "meta": {
                    "title": "分析任务接收",
                    "hidden": true
                }
            },
            {
                "path": "water-solution",
                "component": "analysisSheet/waterQuality/dissolve/dissolve",
                "name": 'water-solution',
                "meta": {
                    "title": "新增水质 溶解氧电极法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-solutionDetail",
                "component": "analysisSheet/waterQuality/dissolve/dissolveDetail",
                "name": 'water-solutionDetail',
                "meta": {
                    "title": "新增水质 溶解氧电极法分析原始记录",
                    "hidden": true
                }
            },
            // {
            //     "path": "water-method",
            //     "component": "analysisSheet/waterQuality/method/method",
            //     "name": 'water-method',
            //     "meta": {
            //         "title": "新增水质 容量法分析原始记录",
            //         "hidden": true
            //     }
            // },
            {
                "path": "water-methodDetail",
                "component": "analysisSheet/waterQuality/methodDetail/methodDetail",
                "name": 'water-methodDetail',
                "meta": {
                    "title": "新增水质 容量法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl37",
                "component": "analysisSheet/waterQuality/tmpl37/index",
                "name": 'water-tmpl37',
                "meta": {
                    "title": "新增水质  菌落总数分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl40",
                "component": "analysisSheet/waterQuality/tmpl40/index",
                "name": 'water-tmpl40',
                "meta": {
                    "title": "新增水质 PH法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl40Detail",
                "component": "analysisSheet/waterQuality/tmpl40/indexDetail",
                "name": 'water-tmpl40Detail',
                "meta": {
                    "title": "新增水质 PH法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl44",
                "component": "analysisSheet/waterQuality/tmpl44/index",
                "name": 'water-tmpl44',
                "meta": {
                    "title": "新增水质 浊度分光光度法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl44Detail",
                "component": "analysisSheet/waterQuality/tmpl44/indexDetail",
                "name": 'water-tmpl44Detail',
                "meta": {
                    "title": "新增水质 浊度分光光度法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl47",
                "component": "analysisSheet/waterQuality/tmpl47/index",
                "name": 'water-tmpl47',
                "meta": {
                    "title": "新增水质 色度分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl47Detail",
                "component": "analysisSheet/waterQuality/tmpl47/indexDetail",
                "name": 'water-tmpl47Detail',
                "meta": {
                    "title": "新增水质 色度分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl48",
                "component": "analysisSheet/waterQuality/tmpl48/index",
                "name": 'water-tmpl48',
                "meta": {
                    "title": "新增水质  重量法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl48Detail",
                "component": "analysisSheet/waterQuality/tmpl48/indexDetail",
                "name": 'water-tmpl48Detail',
                "meta": {
                    "title": "新增水质  重量法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl49",
                "component": "analysisSheet/waterQuality/tmpl49/index",
                "name": 'water-tmpl49',
                "meta": {
                    "title": "新增水质 氟化物分析原始记录(A面)",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl49Detail",
                "component": "analysisSheet/waterQuality/tmpl49/tmpl49Detail",
                "name": 'water-tmpl49Detail',
                "meta": {
                    "title": "新增水质 氟化物分析原始记录(A面)",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl50",
                "component": "analysisSheet/waterQuality/tmpl50/index",
                "name": 'water-tmpl50',
                "meta": {
                    "title": "新增水质 生化需氧量分析原始记录(A面) ",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl50Detail",
                "component": "analysisSheet/waterQuality/tmpl50/requirementDetail",
                "name": 'water-tmpl50Detail',
                "meta": {
                    "title": "新增水质 生化需氧量分析原始记录(A面) ",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl54Detail",
                "component": "analysisSheet/waterQuality/tmpl54/indexDetail",
                "name": 'water-tmpl54Detail',
                "meta": {
                    "title": "新增水质 分光光度法分析原始记录(一)(A面)",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl55",
                "component": "analysisSheet/waterQuality/tmpl55/index",
                "name": 'water-tmpl55',
                "meta": {
                    "title": "新增水质 分光光度法分析原始记录(二)(A面)",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl55Detail",
                "component": "analysisSheet/waterQuality/tmpl55/indexDetail",
                "name": 'water-tmpl55Detail',
                "meta": {
                    "title": "新增水质 分光光度法分析原始记录(二)(A面)",
                    "hidden": true
                }
            },
            {
                "path": "water-leachate",
                "component": "analysisSheet/waterQuality/leachate/leachate",
                "name": 'water-leachate',
                "meta": {
                    "title": "新增水质、固体废物浸出液 前处理记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl129",
                "component": "analysisSheet/waterQuality/tmpl129/index",
                "name": 'water-tmpl129',
                "meta": {
                    "title": "新增水质 总有机碳分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl136",
                "component": "analysisSheet/waterQuality/tmpl136/index",
                "name": 'water-tmpl136',
                "meta": {
                    "title": "新增水质 游离氯、总氯分析原始记录(HJ586-2010) （A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl37",
                "component": "analysisSheet/waterQuality/tmpl37/index",
                "name": 'water-tmpl37',
                "meta": {
                    "title": "水质 菌落总数分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl38",
                "component": "analysisSheet/waterQuality/tmpl38/index",
                "name": 'water-tmpl38',
                "meta": {
                    "title": "水质 总大肠菌群分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl39",
                "component": "analysisSheet/waterQuality/tmpl39/index",
                "name": 'water-tmpl39',
                "meta": {
                    "title": "水质 粪大肠菌群分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl41",
                "component": "analysisSheet/waterQuality/tmpl41/index",
                "name": 'water-tmpl41',
                "meta": {
                    "title": "水质 电导率分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl42",
                "component": "analysisSheet/waterQuality/tmpl42/index",
                "name": 'water-tmpl42',
                "meta": {
                    "title": "水质 嗅和味分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl43",
                "component": "analysisSheet/waterQuality/tmpl43/index",
                "name": 'water-tmpl43',
                "meta": {
                    "title": "水质 肉眼可见物分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl45",
                "component": "analysisSheet/waterQuality/tmpl45/index",
                "name": 'water-tmpl45',
                "meta": {
                    "title": "水质 浊度散射法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl46",
                "component": "analysisSheet/waterQuality/tmpl46/index",
                "name": 'water-tmpl46',
                "meta": {
                    "title": "水质 溶解氧电极法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl50",
                "component": "analysisSheet/waterQuality/tmpl50/index",
                "name": 'water-tmpl50',
                "meta": {
                    "title": "水质 生化需氧量分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl51",
                "component": "analysisSheet/waterQuality/tmpl51/index",
                "name": 'water-tmpl51',
                "meta": {
                    "title": "高氯废水 化学需氧量分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl52",
                "component": "analysisSheet/waterQuality/tmpl52/index",
                "name": 'water-tmpl52',
                "meta": {
                    "title": "水质 容量法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl53",
                "component": "analysisSheet/waterQuality/tmpl53/index",
                "name": 'water-tmpl53',
                "meta": {
                    "title": "水质 碱度分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl54",
                "component": "analysisSheet/waterQuality/tmpl54/index",
                "name": 'water-tmpl54',
                "meta": {
                    "title": "水质 分光光度法分析原始记录（一）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl56",
                "component": "analysisSheet/waterQuality/tmpl56/index",
                "name": 'water-tmpl56',
                "meta": {
                    "title": "水质、固体废物浸出液  前处理记录",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl57",
                "component": "analysisSheet/waterQuality/tmpl57/index",
                "name": 'water-tmpl57',
                "meta": {
                    "title": "水质 原子荧光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl58",
                "component": "analysisSheet/waterQuality/tmpl58/index",
                "name": 'water-tmpl58',
                "meta": {
                    "title": "水质 原子吸收分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl59",
                "component": "analysisSheet/waterQuality/tmpl59/index",
                "name": 'water-tmpl59',
                "meta": {
                    "title": "水质 电感耦合等离子体质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl60",
                "component": "analysisSheet/waterQuality/tmpl60/index",
                "name": 'water-tmpl60',
                "meta": {
                    "title": "水质  吹扫捕集 气相色谱-质谱仪分析原始记录（一）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl61",
                "component": "analysisSheet/waterQuality/tmpl61/index",
                "name": 'water-tmpl61',
                "meta": {
                    "title": "水质、固废浸出液 顶空/气相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl62",
                "component": "analysisSheet/waterQuality/tmpl62/index",
                "name": 'water-tmpl62',
                "meta": {
                    "title": "水质 气相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl63",
                "component": "analysisSheet/waterQuality/tmpl63/index",
                "name": 'water-tmpl63',
                "meta": {
                    "title": "水质、固废浸出液 液相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl64",
                "component": "analysisSheet/waterQuality/tmpl64/index",
                "name": 'water-tmpl64',
                "meta": {
                    "title": "水质、固废浸出液 液相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "water-tmpl65",
                "component": "analysisSheet/waterQuality/tmpl65/index",
                "name": 'water-tmpl65',
                "meta": {
                    "title": "水质 红外分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl66",
                "component": "analysisSheet/ambientAir/tmpl66/index",
                "name": 'air-tmpl66',
                "meta": {
                    "title": "环境空气和废气 分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl68",
                "component": "analysisSheet/ambientAir/tmpl68/index",
                "name": 'air-tmpl68',
                "meta": {
                    "title": "环境空气和废气 总烃/甲烷/非甲烷总烃分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl69",
                "component": "analysisSheet/ambientAir/tmpl69/index",
                "name": 'air-tmpl69',
                "meta": {
                    "title": "环境空气和废气 滤头、滤筒、滤膜 初重原始记录",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl70",
                "component": "analysisSheet/ambientAir/tmpl70/index",
                "name": 'air-tmpl70',
                "meta": {
                    "title": "环境空气 离子选择电极法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl71",
                "component": "analysisSheet/ambientAir/tmpl71/index",
                "name": 'air-tmpl71',
                "meta": {
                    "title": "环境空气和废气  挥发性有机物前处理原始记录",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl72",
                "component": "analysisSheet/ambientAir/tmpl72/index",
                "name": 'air-tmpl72',
                "meta": {
                    "title": "环境空气和废气 热脱附-气相色谱质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl73",
                "component": "analysisSheet/ambientAir/tmpl73/index",
                "name": 'air-tmpl73',
                "meta": {
                    "title": "环境空气和废气  容量法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl74",
                "component": "analysisSheet/ambientAir/tmpl74/index",
                "name": 'air-tmpl74',
                "meta": {
                    "title": "环境空气和废气  原子吸收分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl75",
                "component": "analysisSheet/ambientAir/tmpl75/index",
                "name": 'air-tmpl75',
                "meta": {
                    "title": "环境空气和废气 电感耦合等离子体质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl76",
                "component": "analysisSheet/ambientAir/tmpl76/index",
                "name": 'air-tmpl76',
                "meta": {
                    "title": "环境空气和废气 气相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl77",
                "component": "analysisSheet/ambientAir/tmpl77/index",
                "name": 'air-tmpl77',
                "meta": {
                    "title": "环境空气和废气 颗粒物分析原始记录（A面）",
                    "hidden": true
                }
            },

            {
                "path": "air-tmpl81",
                "component": "analysisSheet/ambientAir/tmpl81/index",
                "name": 'air-tmpl81',
                "meta": {
                    "title": "环境空气和废气 离子色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "air-tmpl135",
                "component": "analysisSheet/ambientAir/tmpl135/index",
                "name": 'air-tmpl135',
                "meta": {
                    "title": "环境空气和废气 液相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl82",
                "component": "analysisSheet/soil/tmpl82/index",
                "name": 'soil-tmpl82',
                "meta": {
                    "title": "土壤/沉积物 pH分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl83",
                "component": "analysisSheet/soil/tmpl83/index",
                "name": 'soil-tmpl83',
                "meta": {
                    "title": "土壤、固体废物 样品制备原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl84",
                "component": "analysisSheet/soil/tmpl84/index",
                "name": 'soil-tmpl84',
                "meta": {
                    "title": "土壤、固体废物 液相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl85",
                "component": "analysisSheet/soil/tmpl85/index",
                "name": 'soil-tmpl85',
                "meta": {
                    "title": "土壤 吹扫捕集-气相色谱质谱法分析原始记录（一）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl86",
                "component": "analysisSheet/soil/tmpl86/index",
                "name": 'soil-tmpl86',
                "meta": {
                    "title": "土壤 VOC采样瓶称重原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl87",
                "component": "analysisSheet/soil/tmpl87/index",
                "name": 'soil-tmpl87',
                "meta": {
                    "title": "土壤 气相色谱质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl88",
                "component": "analysisSheet/soil/tmpl88/index",
                "name": 'soil-tmpl88',
                "meta": {
                    "title": "土壤 气相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl89",
                "component": "analysisSheet/soil/tmpl89/index",
                "name": 'soil-tmpl89',
                "meta": {
                    "title": "土壤 氟化物分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl90",
                "component": "analysisSheet/soil/tmpl90/index",
                "name": 'soil-tmpl90',
                "meta": {
                    "title": "土壤 容量法分析原始记录（一）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl91",
                "component": "analysisSheet/soil/tmpl91/index",
                "name": 'soil-tmpl91',
                "meta": {
                    "title": "土壤 分光光度法分析原始记录（一）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl92",
                "component": "analysisSheet/soil/tmpl92/index",
                "name": 'soil-tmpl92',
                "meta": {
                    "title": "土壤 分光光度法分析原始记录（二）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl93",
                "component": "analysisSheet/soil/tmpl93/index",
                "name": 'soil-tmpl93',
                "meta": {
                    "title": "土壤和沉积物、固体废物 前处理原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl94",
                "component": "analysisSheet/soil/tmpl94/index",
                "name": 'soil-tmpl94',
                "meta": {
                    "title": "土壤和沉积物 原子荧光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl95",
                "component": "analysisSheet/soil/tmpl95/index",
                "name": 'soil-tmpl95',
                "meta": {
                    "title": "土壤和沉积物 原子吸收分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl96",
                "component": "analysisSheet/soil/tmpl96/index",
                "name": 'soil-tmpl96',
                "meta": {
                    "title": "土壤和沉积物 电感耦合等离子体质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl97",
                "component": "analysisSheet/soil/tmpl97/index",
                "name": 'soil-tmpl97',
                "meta": {
                    "title": "土壤 重量法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl98",
                "component": "analysisSheet/soil/tmpl98/index",
                "name": 'soil-tmpl98',
                "meta": {
                    "title": "土壤 重量法分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl99",
                "component": "analysisSheet/soil/tmpl99/index",
                "name": 'soil-tmpl99',
                "meta": {
                    "title": "土壤 自然含水量分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl100",
                "component": "analysisSheet/soil/tmpl100/index",
                "name": 'soil-tmpl100',
                "meta": {
                    "title": "土壤 饱和导水率分析原始记录（环刀法）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl101",
                "component": "analysisSheet/soil/tmpl101/index",
                "name": 'soil-tmpl101',
                "meta": {
                    "title": "土壤 孔隙度分析原始记录（环刀法）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl122",
                "component": "analysisSheet/soil/tmpl122/index",
                "name": 'soil-tmpl122',
                "meta": {
                    "title": "土壤 火焰光度法原始记录（有效态类）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl123",
                "component": "analysisSheet/soil/tmpl123/index",
                "name": 'soil-tmpl123',
                "meta": {
                    "title": "土壤 机械组成（吸管法）分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl130",
                "component": "analysisSheet/soil/tmpl130/index",
                "name": 'soil-tmpl130',
                "meta": {
                    "title": "土壤和沉积物  气相色谱法分析原始记录（二）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl132",
                "component": "analysisSheet/soil/tmpl132/index",
                "name": 'soil-tmpl132',
                "meta": {
                    "title": "土壤 火焰光度法原始记录（水溶性钾钠）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl133",
                "component": "analysisSheet/soil/tmpl133/index",
                "name": 'soil-tmpl133',
                "meta": {
                    "title": "土壤 原子吸收分光光度法原始记录（水溶性钙镁）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl139",
                "component": "analysisSheet/soil/tmpl139/index",
                "name": 'soil-tmpl139',
                "meta": {
                    "title": "土壤 容量法分析原始记录（二）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "soil-tmpl140",
                "component": "analysisSheet/soil/tmpl140/index",
                "name": 'soil-tmpl140',
                "meta": {
                    "title": "土壤 容量法原始记录(三)（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl78",
                "component": "analysisSheet/gufei/tmpl78/index",
                "name": 'gufei-tmpl78',
                "meta": {
                    "title": "固定污染源废气 颗粒物分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl79",
                "component": "analysisSheet/gufei/tmpl79/index",
                "name": 'gufei-tmpl79',
                "meta": {
                    "title": "固定污染源废气 低浓度颗粒物分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl102",
                "component": "analysisSheet/gufei/tmpl102/index",
                "name": 'gufei-tmpl102',
                "meta": {
                    "title": "固废浸出液 原子吸收分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl103",
                "component": "analysisSheet/gufei/tmpl103/index",
                "name": 'gufei-tmpl103',
                "meta": {
                    "title": "固体废物 原子吸收分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl104",
                "component": "analysisSheet/gufei/tmpl104/index",
                "name": 'gufei-tmpl104',
                "meta": {
                    "title": "固废浸出液 原子荧光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl105",
                "component": "analysisSheet/gufei/tmpl105/index",
                "name": 'gufei-tmpl105',
                "meta": {
                    "title": "固体废物 原子荧光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl106",
                "component": "analysisSheet/gufei/tmpl106/index",
                "name": 'gufei-tmpl106',
                "meta": {
                    "title": "固废浸出液 电感耦合等离子体质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl107",
                "component": "analysisSheet/gufei/tmpl107/index",
                "name": 'gufei-tmpl107',
                "meta": {
                    "title": "固体废物 电感耦合等离子体质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl108",
                "component": "analysisSheet/gufei/tmpl108/index",
                "name": 'gufei-tmpl108',
                "meta": {
                    "title": "固体废物浸出液 离子色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl109",
                "component": "analysisSheet/gufei/tmpl109/index",
                "name": 'gufei-tmpl109',
                "meta": {
                    "title": "固体废物 离子色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl110",
                "component": "analysisSheet/gufei/tmpl110/index",
                "name": 'gufei-tmpl110',
                "meta": {
                    "title": "固体废物 原子吸收分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl111",
                "component": "analysisSheet/gufei/tmpl111/index",
                "name": 'gufei-tmpl111',
                "meta": {
                    "title": "固体废物 分光光度法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl112",
                "component": "analysisSheet/gufei/tmpl112/index",
                "name": 'gufei-tmpl112',
                "meta": {
                    "title": "固体废物 有机质（热灼减率）分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl113",
                "component": "analysisSheet/gufei/tmpl113/index",
                "name": 'gufei-tmpl113',
                "meta": {
                    "title": "固体废物 腐蚀性分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl114",
                "component": "analysisSheet/gufei/tmpl114/index",
                "name": 'gufei-tmpl114',
                "meta": {
                    "title": "固体废物 闪点分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl115",
                "component": "analysisSheet/gufei/tmpl115/index",
                "name": 'gufei-tmpl115',
                "meta": {
                    "title": "土壤/固体废物/沉积物 干物质和水分分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl116",
                "component": "analysisSheet/gufei/tmpl116/index",
                "name": 'gufei-tmpl116',
                "meta": {
                    "title": "固体废物 有机质（热灼减率）分析原始记录",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl117",
                "component": "analysisSheet/gufei/tmpl117/index",
                "name": 'gufei-tmpl117',
                "meta": {
                    "title": "固体废物 浸出毒性浸出方法 醋酸缓冲溶液法",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl118",
                "component": "analysisSheet/gufei/tmpl118/index",
                "name": 'gufei-tmpl118',
                "meta": {
                    "title": "固体废物 浸出毒性浸出方法 水平振荡法",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl127",
                "component": "analysisSheet/gufei/tmpl127/index",
                "name": 'gufei-tmpl127',
                "meta": {
                    "title": "固体废物  顶空/气相色谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl128",
                "component": "analysisSheet/gufei/tmpl128/index",
                "name": 'gufei-tmpl128',
                "meta": {
                    "title": "固体废物/固废浸出液 气相色谱质谱法分析原始记录（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl137",
                "component": "analysisSheet/gufei/tmpl137/index",
                "name": 'gufei-tmpl137',
                "meta": {
                    "title": "固体废物 顶空-气相色谱质谱法分析原始记录（一）（A面）",
                    "hidden": true
                }
            },
            {
                "path": "gufei-tmpl138",
                "component": "analysisSheet/gufei/tmpl138/index",
                "name": 'gufei-tmpl138',
                "meta": {
                    "title": "固废浸出液 顶空-气相色谱质谱法分析原始记录（一）（A面）",
                    "hidden": true
                }
            },

        ]
    },

]

const userRouter = getUserRouter()
export const usePermissionStore = defineStore("permission", () => {
    // 所有路由，包括静态和动态路由
    const routes = ref<RouteRecordRaw[]>([]);
    // 混合模式左侧菜单
    const mixLeftMenus = ref<RouteRecordRaw[]>([]);
    // 路由是否已加载
    const isRoutesLoaded = ref(false);

    /**
     * 生成动态路由
     */
    function generateRoutes() {
        return new Promise<RouteRecordRaw[]>((resolve, reject) => {
            // MenuAPI.getRoutes()
            //     .then((data) => {
            //         console.log(data)
            //         debugger
            //         const dynamicRoutes = transformRoutes(data);
            //         routes.value = constantRoutes.concat(dynamicRoutes);
            //         isRoutesLoaded.value = true;
            //         resolve(dynamicRoutes);
            //     })
            //     .catch((error) => {
            //         reject(error);
            //     });
            const userRouter = getUserRouter()
            try {
                const loginData = JSON.parse(userRouter)
                const userRoutes = loginData.map(item => item.name);
                const cleanUserRoutes = userRoutes.filter(route => route !== null);
                // const userRoutes = ["analyse/sample"];
                console.log(cleanUserRoutes)
                // const filteredRoutes = router.filter(route => userRoutes.includes(route.name.slice(1))); // 过滤掉不需要的路由
                const filteredRoutes = filterRoutes(router, cleanUserRoutes);
                console.log(filteredRoutes)
                const dynamicRoutes = transformRoutes(filteredRoutes);  // 使用 transformRoutes 转换数据
                routes.value = constantRoutes.concat(dynamicRoutes);  // 合并静态路由和动态路由
                isRoutesLoaded.value = true;  // 标记路由加载完成
                resolve(dynamicRoutes);  // 返回动态路由
            } catch (error) {
                reject(error);  // 处理错误
            }

        });
    }

    // 递归过滤父级和子级路由
    function filterRoutes(routes, userRoutes) {

        return routes.reduce((filtered, route) => {
            const fullPath = route.name;

            const parentRouteInUserRoutes = userRoutes.some(routePath => routePath.startsWith(fullPath));

            if (parentRouteInUserRoutes || userRoutes.includes(route.name)) {
                let newRoute = { ...route };

                if (route.children && route.children.length > 0) {
                    newRoute.children = route.children.filter(child => {
                        const fullChildPath = `${route.name}/${child.name}`;
                        return userRoutes.includes(fullChildPath) || (child.meta && child.meta.hidden);
                    });
                }

                filtered.push(newRoute);
            }
            return filtered;
        }, []);
    }



    /**
     * 混合模式菜单下根据顶部菜单路径设置左侧菜单
     *
     * @param topMenuPath - 顶部菜单路径
     */
    const setMixLeftMenus = (topMenuPath: string) => {
        const matchedItem = routes.value.find((item) => item.path === topMenuPath);
        if (matchedItem && matchedItem.children) {
            mixLeftMenus.value = matchedItem.children;
        }
    };

    /**
     * 重置路由
     */
    const resetRouter = () => {
        // 删除动态路由，保留静态路由
        routes.value.forEach((route) => {
            if (route.name && !constantRoutes.find((r) => r.name === route.name)) {
                // 从 router 实例中移除动态路由
                router.removeRoute(route.name);
            }
        });

        routes.value = [];
        mixLeftMenus.value = [];
        isRoutesLoaded.value = false;
    };

    return {
        routes,
        generateRoutes,
        mixLeftMenus,
        setMixLeftMenus,
        isRoutesLoaded,
        resetRouter,
    };
});

/**
 * 转换路由数据为组件
 */
const transformRoutes = (routes: RouteVO[]) => {
    const asyncRoutes: RouteRecordRaw[] = [];
    routes.forEach((route) => {
        const tmpRoute = {...route} as RouteRecordRaw;
        // 顶级目录，替换为 Layout 组件
        if (tmpRoute.component?.toString() == "Layout") {
            tmpRoute.component = Layout;
        } else {
            // 其他菜单，根据组件路径动态加载组件
            const component = modules[`../../views/${tmpRoute.component}.vue`];
            if (component) {
                tmpRoute.component = component;
            } else {
                tmpRoute.component = modules["@/views/error-page/404.vue"];
            }
        }

        if (tmpRoute.children) {
            tmpRoute.children = transformRoutes(route.children);
        }

        asyncRoutes.push(tmpRoute);
    });

    return asyncRoutes;
};

/**
 * 在组件外使用 Pinia store 实例 @see https://pinia.vuejs.org/core-concepts/outside-component-usage.html
 */
export function usePermissionStoreHook() {
    return usePermissionStore(store);
}
